home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.dcs.warwick.ac.uk!not-for-mail
- From: D.C.Molero@dcs.warwick.ac.uk (Daniel Castillo Molero)
- Subject: dereferencing pointer to incomplete type
- X-Nntp-Posting-Host: angel
- Message-ID: <1996Mar3.040741.27234@dcs.warwick.ac.uk>
- Sender: news@dcs.warwick.ac.uk (Network News)
- Organization: Department of Computer Science, Warwick University, England
- Date: Sun, 3 Mar 1996 04:07:41 GMT
-
-
- Hi everybody.
- I wonder if anybody can help me to debug the short code below.
- It is supposed to calculate the area of a polygon, but when I compile
- it with gcc program.c, it gives me the following errors,
-
- program.c: In function `calc_area':
- program.c:22: warning: assignment from incompatible pointer type
- program.c:24: dereferencing pointer to incomplete type
- program.c:24: dereferencing pointer to incomplete type
- program.c:26: warning: assignment from incompatible pointer type
-
-
- which I don't understand at all.
-
- I would appreciate very much any sort of help.
-
- ------------------
-
- struct polygon
- {
- int tried;
- double x, y;
- int dir, numtimes, conv;
- struct polyg *next;
- };
-
-
- void triang(double a0, double a1, double b0, double b1, double c0, \
- double c1, double* result) {
- *result = a0 * b1 - a1 * b0 + \
- a1 * c0 - a0 * c1 + \
- b0 * c1 - c0 * b1;
- }
-
- void calc_area(struct polygon* polyg, double* area) {
- struct polygon* p;
- double result;
- p = polyg->next;
- while (p->next != 0) {
- triang(polyg->x, polyg->y, p->x, p->y, (p->next)->x, (p->next)->y, &result);
- *area = *area + result;
- p = p->next;
- }
- }
- --
- * Daniel Castillo. danmol@dcs.warwick.ac.uk *
-
-
-